import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NumberVO, NumberForm, NumberQuery } from '@/api/number/number/types';

/**
 * 查询会员管理列表
 * @param query
 * @returns {*}
 */

export const listNumber = (query?: NumberQuery): AxiosPromise<NumberVO[]> => {
  return request({
    url: '/number/number/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询会员管理详细
 * @param id
 */
export const getNumber = (id: string | number): AxiosPromise<NumberVO> => {
  return request({
    url: '/number/number/' + id,
    method: 'get'
  });
};

/**
 * 新增会员管理
 * @param data
 */
export const addNumber = (data: NumberForm) => {
  return request({
    url: '/number/number',
    method: 'post',
    data: data
  });
};

/**
 * 修改会员管理
 * @param data
 */
export const updateNumber = (data: NumberForm) => {
  return request({
    url: '/number/number',
    method: 'put',
    data: data
  });
};

/**
 * 删除会员管理
 * @param id
 */
export const delNumber = (id: string | number | Array<string | number>) => {
  return request({
    url: '/number/number/' + id,
    method: 'delete'
  });
};


/**
 * 根据ID列表导出会员列表
 * @param ids 需要导出的会员ID列表
 */
export const exportSelectedNumber = (ids: Array<string | number>): AxiosPromise<Blob> => {
  return request({
    url: '/number/number/exportSelected',
    method: 'post',
    data: ids,
    headers: {
      'Content-Type': 'application/json'
    },
    responseType: 'blob' // 确保响应类型为blob，以便处理文件下载
  });
};


/**
 * 清空表数据
 * 
 */

export const clearNumber = () => {
  return request({
    url: '/number/number/clear',
    method: 'delete'
  });
};
